home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,gnu.gcc.help
- Path: in1.uu.net!tellab5!news
- From: Joe Toth <toth@tellabs.com>
- Subject: Re: Casting unsigned short as unsigned int -> Bus error
- X-Nntp-Posting-Host: sunh25
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <1996Jan26.140949.14999@tellab5.tellabs.com>
- Sender: news@tellab5.tellabs.com (News)
- Content-Transfer-Encoding: 7bit
- Organization: Tellabs Operations, Inc.
- References: <simmons.820857453@rzdspc1> <820879186snz@genesis.demon.co.uk> <4e8v6t$bd2@crl.crl.com>
- Mime-Version: 1.0
- Date: Fri, 26 Jan 1996 14:09:49 GMT
- X-Mailer: Mozilla 1.1 (X11; U; SunOS 4.1.3 sun4c)
- X-Url: news:4e8v6t$bd2@crl.crl.com
-
- gherlein@crl.com (Greg Herlein) wrote:
- <<<<SNIP>>>>>
- >This sounds to me like a problem I had a while back - though I'm not a
- >Sparc guru enough to know for sure. I was reading elements from
- >structures like this too, and got bus errors for not reading on 32 bit
- >boundaries. Does it work if you read the myshort variable into a
- >short *then* cast it to an unsigned int? I'm not sure what the order
- >of operations is on the assignment... I would think the dererencing of
- >the stucture element poinet would be first, but what do I know?
-
- Yep, I spent a number of weeks trying to fix this problem on some
- code running on Sparcs with SunOS. Then I checked the man pages on the
- Sun Workstation and found the C compiler option;
-
- -misalign Generate code to allow loading and storage of
- misaligned data (Sun-4 systems only).
-
- End of problems... at least until we have to port the code to
- some other system that doesn't like the alignments.
-
- >
- >Good luck!
-
- Ditto....
-
- >
- >--
- >Greg Herlein
- >gherlein@crl.com
- >http://www.crl.com/www/users/gh/gherlein (under construction, but there!)
- >Vallejo, CA
-
- --
- _ _ ___ --------------------------+---------------------------------
- | / _ | Joseph G. Toth Jr. | Tellabs Operations, Inc.
- \_| \_/ | | toth@tellabs.com
-
- > Every program has at least one bug and can be shortened by at least
- > one instruction -- from which, by induction, it is evident that every
- > program can be reduced to one instruction that does not work.
- > -- Ken Arnold
-
-